package com.haiyou.common.spring.listener;

import lombok.Setter;

import java.lang.reflect.Method;

/**
 * @Author: xlight
 */
@Setter
public class SpringRobot {

    private Object robotServiceObject;

    private SpringRobot(){}

    private static SpringRobot springRobot = new SpringRobot();

    public static SpringRobot getInstance(){
        return springRobot;
    }

    public void invokeRobotInit(){
        try {
            Class<?> clazz = robotServiceObject.getClass();
            Method method = clazz.getMethod("init");
            method.invoke(robotServiceObject);
        }catch (Exception e) {

        }
    }

    public void invokeRobotDestroy(){
        try {
            Class<?> clazz = robotServiceObject.getClass();
            Method method = clazz.getMethod("destroy");
            method.invoke(robotServiceObject);
        } catch (Exception e) {
        }
    }

    public void invokeRobotChange(){
        try {
            Class<?> clazz = robotServiceObject.getClass();
            Method method = clazz.getMethod("change");
            method.invoke(robotServiceObject);
        } catch (Exception e) {
        }
    }
}
